<?php


namespace App\Http\Controllers\Api\v1;


use App\common;
use App\Logic\HousingLogic;
use App\Models\Residential;
use Illuminate\Http\Request;

class HousingController
{

    /**
     * 房源详情
     * @param Request $request
     * @return array|false|string
     */
    public function detail(Request $request)
    {
        $id = $request->get('id');
        try {
            $data = Residential::detail($id);
            if ($data) {
                return common::success(20000, '', $data);
            }
            return common::fail('201', '', '数据已被删除');
        } catch (\Exception $exception) {
            return common::fail('201', '', $exception->getMessage());
        }
    }


    public function houseShow(Request $request)
    {
        try {
            $keyword = $request->get('address');
            $data = HousingLogic::search($keyword);
            return common::success(20000,$data,'success');
        }catch (\Exception $exception){
            return common::fail(201,'',$exception->getMessage());
        }

    }

}
